//
//  LBCalenderTitleView.m
//  jslj
//
//  Created by 杨庆人 on 2018/4/10.
//  Copyright © 2018年 广东联结电子商务有限公司. All rights reserved.
//

#import "LBCalenderTitleView.h"
@interface LBCalenderTitleView ()
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *deleButton;
@end
@implementation LBCalenderTitleView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setCalenderTitleView];
    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 22)];
        _titleLabel.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.text = @"选择日期";
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.center = CGPointMake(self.center.x, self.center.y +6);
    }
    return _titleLabel;
}

- (UIButton *)deleButton {
    if (!_deleButton) {
        _deleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleButton.frame = CGRectMake(CGRectGetMaxX(self.bounds) -30, 0, 30, 30);
        [_deleButton setImage:[UIImage imageNamed:@"LBCalendarPickerView.bundle/X"] forState:UIControlStateNormal];
        _deleButton.center = CGPointMake(CGRectGetMaxX(self.bounds) -30, self.titleLabel.center.y);
        [_deleButton addTarget:self action:@selector(deleButtonClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleButton;
}

- (void)setCalenderTitleView {
    [self addSubview:self.titleLabel];
    [self addSubview:self.deleButton];
}

- (void)deleButtonClick {
    !self.closeBlock ? :self.closeBlock();
}

@end
